-----------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\jgw12\Dropbox\Research\PersPartyBook\Data\FKTW-reproduction\C
> h1.log
  log type:  text
 opened on:  26 Jul 2023, 15:52:21

. 
.         ******************************
.         **** Set directory, seed *****
.         ******************************
.                 set more off 

.                 set matsize 1000
set matsize ignored.
    Matrix sizes are no longer limited by c(matsize) in modern Statas.  Matrix
    sizes are now limited by edition of Stata.  See limits for more details.

.                 global seed ="984353"

.                 set scheme plotplain

.                 cd "$dir"
C:\Users\jgw12\Dropbox\Research\PersPartyBook\Data\FKTW-reproduction

.  
.         ************************************************
.         **** Global patterns of democratic collapse ****
.         ************************************************
.                 use  "GWFglobal2020.dta" ,clear

.                  * Update for collapse in 2020 *
.                 recode gwf_back (0=1) if year==2020 & (gwf_country=="Mali")
(1 changes made to gwf_back)

.                 tab gwf_back

   gwf_back |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      9,270       98.96       98.96
          1 |         97        1.04      100.00
------------+-----------------------------------
      Total |      9,367      100.00

.                 egen cy = count(gwf_back) if gwf_back==1,by(year)
(9,270 missing values generated)

.                 egen collapserate = mean(gwf_back) if gwf_democracy==1 | gwf_prov
> isional==1,by(year)
(5,291 missing values generated)

.                 sort cowcode year

.                 merge cowcode year using pers-use
(you are using old merge syntax; see [D] merge for new syntax)
(variable year was float, now double to accommodate using data's values)
(variable cowcode was float, now double to accommodate using data's values)

.                 tab _merge

     _merge |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |      6,975       74.46       74.46
          3 |      2,392       25.54      100.00
------------+-----------------------------------
      Total |      9,367      100.00

.                 drop _merge

.                 qui reg persparty ld

.                 predict yhatpers, r
(6,975 missing values generated)

.                 qui sum yhatpers

.                 replace yhatpers = (yhatpers + abs(r(min)))/(abs(r(min))+r(max))
(2,392 real changes made)

.                 egen yrpers = mean(yhatpers),by(year)
(4,932 missing values generated)

.                 qui reg create ld 

.                 predict yhatcreate, r
(6,975 missing values generated)

.                 qui sum yhatcreate

.                 replace yhatcreate = (yhatcreate + abs(r(min)))/(abs(r(min))+r(ma
> x))
(2,392 real changes made)

.                 egen yrcreate = mean(yhatcreate),by(year)
(4,932 missing values generated)

. 
.                 gen backtype=""
(9,367 missing values generated)

.                 replace backtype ="rebellion" if country=="Afghanistan" & year==2
> 019
variable backtype was str1 now str9
(1 real change made)

.                 replace backtype ="powergrab" if country=="Armenia" & year==1994
(1 real change made)

.                 replace backtype ="rebellion" if country=="Azerbaijan" & year==19
> 93
(1 real change made)

.                 replace backtype ="powergrab" if country=="Bangladesh" & year==20
> 14
(1 real change made)

.                 replace backtype ="powergrab" if country=="Benin" & year==2019
(1 real change made)

.                 replace backtype ="coup" if country=="Bolivia" & year==2019
(1 real change made)

.                 replace backtype ="coup" if country=="Burundi" & year==1996
(1 real change made)

.                 replace backtype ="powergrab" if country=="Burundi" & year==2010
(1 real change made)

.                 replace backtype ="rebellion" if country=="Central African Republ
> ic" & year==2003
(1 real change made)

.                 replace backtype ="coup" if country=="Egypt" & year==2013
(1 real change made)

.                 replace backtype ="powergrab" if country=="Guinea Bissau" & year=
> =2002
(1 real change made)

.                 replace backtype ="powergrab" if country=="Haiti" & year==1999
(1 real change made)

.                 replace backtype ="powergrab" if country=="Hungary" & year==2018
(1 real change made)

.                 replace backtype ="coup" if country=="Madagascar" & year==2009
(1 real change made)

.                 replace backtype ="coup" if country=="Mali" & year==2012
(1 real change made)

.                 replace backtype ="coup" if country=="Mali" & year==2020
(1 real change made)

.                 replace backtype ="coup" if country=="Mauritania" & year==2008
(1 real change made)

.                 replace backtype ="powergrab" if country=="Nicaragua" & year==201
> 6
(1 real change made)

.                 replace backtype ="coup" if country=="Niger" & year==1996
(1 real change made)

.                 replace backtype ="powergrab" if country=="Niger" & year==2009
(1 real change made)

.                 replace backtype ="coup" if country=="Pakistan" & year==1999
(1 real change made)

.                 replace backtype ="powergrab" if country=="Peru" & year==1992
(1 real change made)

.                 replace backtype ="rebellion" if country=="Republic of Congo" & y
> ear==1997
(1 real change made)

.                 replace backtype ="powergrab" if country=="Russia" & year==1993
(1 real change made)

.                 replace backtype ="powergrab" if country=="Serbia" & year==2018
(1 real change made)

.                 replace backtype ="rebellion" if country=="Sierra Leone" & year==
> 1997
(1 real change made)

.                 replace backtype ="powergrab" if country=="Sri Lanka" & year==201
> 0
(1 real change made)

.                 replace backtype ="powergrab" if country=="Sri Lanka" & year==202
> 0
(1 real change made)

.                 replace backtype ="coup" if country=="Thailand" & year==1991
(1 real change made)

.                 replace backtype ="coup" if country=="Thailand" & year==2006
(1 real change made)

.                 replace backtype ="coup" if country=="Thailand" & year==2014
(1 real change made)

.                 replace backtype ="powergrab" if country=="Turkey" & year==2016
(1 real change made)

.                 replace backtype ="powergrab" if country=="Ukraine" & year==2012
(1 real change made)

.                 replace backtype ="powergrab" if country=="Venezuela" & year==200
> 5
(1 real change made)

.                 replace backtype ="powergrab" if country=="Zambia" & year==1996
(1 real change made)

.                 
.                 gen grabback = backtype=="powergrab" if gwf_democracy ==1  & year
> >1990
(6,930 missing values generated)

.                 gen coupback = backtype=="coup" if gwf_democracy ==1  & year>1990
(6,930 missing values generated)

.                 
.                 egen cy_coup = total(coupback) if persparty~=.,by(year)
(6,975 missing values generated)

.                 egen cy_grab = total(grabback) if persparty~=.,by(year)
(6,975 missing values generated)

.                 twoway (lpoly cy_grab year if year>1990,bw(3)xlab(1990(5)2020)yla
> b(0(.5)1)) ///
>                         (lpoly cy_coup year if year>1990,bw(3)legend(lab(1 "Democ
> ratic collapse by {bf:incumbent power grab}") ///
>                         lab(2 "Democratic collapse by {bf:coup}")pos(12)ring(0)co
> l(1))xtit(Year) ytit("Yearly average  #"))

.                 gr export "$dir\golden\Ch1-Dem-Collapse.pdf",as(pdf)replace 
file
    C:\Users\jgw12\Dropbox\Research\PersPartyBook\Data\FKTW-reproduction\golden\C
    > h1-Dem-Collapse.pdf saved as PDF format

. 
.         *********************************************  THE END ******************
> *******************************
.         
.         log close
      name:  <unnamed>
       log:  C:\Users\jgw12\Dropbox\Research\PersPartyBook\Data\FKTW-reproduction\C
> h1.log
  log type:  text
 closed on:  26 Jul 2023, 15:52:24
-----------------------------------------------------------------------------------
